#ifndef _SD_SPEED_H_
#define _SD_SPEED_H_

#include <QLabel>
#include <QLineEdit>
#include <QComboBox>
#include <QPushButton>
#include <QGridLayout>
#include <QString>
#include <QTimer>
#include <QList>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <qdebug.h>
#include <qfile.h>
#include <QFile>
#include <sys/ioctl.h>
#include <unistd.h>
#include <QString>
#include <QNetworkInterface>
#include <QList>
#include <QFrame>

#include <QWidget>
#include "jwidget/jdialog.h"
#include <QDialog>
#include "weiqiantools/serialport.h"
#include "weiqiantools/weiqianfunctions.h"
#include "weiqiantools/serialportreadthread.h"
#include "InputMethod/inputmethod.h"

extern "C"
{
	#include <sys/types.h>
	#include <sys/stat.h>
	#include <unistd.h>
	#include <stdio.h>
	#include <netinet/in.h>
	#include <netinet/ip.h>
	#include <netinet/ip_icmp.h>
	#include <unistd.h>
	#include <signal.h>
	#include <arpa/inet.h>
	#include <errno.h>
	#include <sys/time.h>
	#include <string.h>	
	#include <netdb.h>
	#include <pthread.h>
	#include <sys/ioctl.h>
	#include <net/if.h>
	#include <net/route.h>
}

extern long long get_file_size(const char *path)  ;
extern float get_time_time(const char *str);
extern int isDigitStr(QString src);


class SdSpeedTest : public QDialog
{
    Q_OBJECT
 public:
	SdSpeedTest(QWidget *parent = 0);
	~SdSpeedTest();

	QPushButton *start_bt;
	QPushButton *clear_bt;
	QPushButton *remove_bt;
	QPushButton *exit_bt;
	QPushButton *dest_path_bt;
	QPushButton *read_bt;

	QGroupBox 	*write_param_grpbox;
	QGroupBox 	*read_param_grpbox;
	QGroupBox 	*write_result_grpbox;
	QGroupBox 	*read_result_grpbox;
	QGroupBox   *bar_grpbox;

	QLabel *src_label;
	QLabel *dest_label;
	QLabel *filename_label;
	QLabel *filesize_label;
	
	QLabel *read_src_filesize_label;
	QLabel *read_dest_filesize_label;
	QLabel *read_time_label;
	QLabel *read_speed_label;

	QLabel *read_src_filesize_data_label;
	QLabel *read_dest_filesize_data_label;
	QLabel *read_time_data_label;
	QLabel *read_speed_data_label;

	QLabel *write_src_filesize_label;
	QLabel *write_dest_filesize_label;
	QLabel *write_time_label;
	QLabel *write_speed_label;

	QLabel *write_src_filesize_data_label;
	QLabel *write_dest_filesize_data_label;
	QLabel *write_time_data_label;
	QLabel *write_speed_data_label;

	QLineEdit *src_path_edit;
	QLineEdit *dest_path_edit;
	QLineEdit *filename_edit;
	QLineEdit *filesize_edit;
	QTextEdit *debug_edit;

	QString usb_sd_path;
	QString src_file_path;
	QString dest_file_path;
	QString dest_file_name;
	QString src_file_name;
	QString cmd_read;
	QString cmd_write;

	QProgressBar *pProgressBar;

	QScrollArea *psplitter; //一个可滚动区域

	float read_speed;
	float write_speed;
	float read_time;
	float write_time;
	long long src_file_size;
	long long dest_file_size;

	InputMethod *im;
	
	
private: 
	void debug_add_text(const char *str);
	void debug_add_text(QString str);
	bool check_valid(void);
	void sd_usb_read_test(void);
	void sd_usb_write_test(void);
	bool ping_socket_init(void);
	int rawsock;

private slots:
	void dialog_close();
	void open_file();
	void debug_edit_clear();
	void start_sd_usb_test();
	void createImConnect(QString ObjName);
	void remove_test_file(void);
};

#endif
